package com.example.academicsystem.server.dao;

import com.example.academicsystem.pojo.dto.CourseDto;
import com.example.academicsystem.pojo.dto.StudentCourseDeleteDto;
import com.example.academicsystem.pojo.dto.StudentCourseInsertDto;
import com.example.academicsystem.pojo.dto.StudentGradePageQueryDto;
import com.example.academicsystem.pojo.entity.Grade;
import com.example.academicsystem.pojo.vo.CourseTableVo;
import com.example.academicsystem.pojo.vo.CourseVo;
import com.example.academicsystem.pojo.vo.StudentGradeVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface StudentMapper {

    @Select("select course_id,course_name,score,teacher_name from grade where student_id=#{studentId}")
    List<StudentGradeVo> gradeSelectAll(String studentId);
    /**
     * 分页查询
     * @param studentGradePageQueryDto
     * @return
    * */
    Page<StudentGradeVo> gradePageQuery(StudentGradePageQueryDto studentGradePageQueryDto);
    /**
     * 根据课程名称查询成绩
     * */
    Page<StudentGradeVo> studentGradeByCourseName(StudentGradePageQueryDto studentGradePageQueryDto);
    /**
     * 分页查询课程
    * */
    Page<CourseVo> coursePageQuery(List<String> courseIdList,String courseName,String courseId);
    /**
     * 根据学号查询课程号
    * */
    @Select("select course_id from course_student where student_id=#{studentId}")
    List<String> studentCourseSelectAll(String studentId);
    /**
     * 根据学期查询课表
     * */
    List<CourseTableVo> courseTableQuery(List<String> courseIdList, int term);

    @Insert("insert into course_student(course_id,student_id) values (#{courseId},#{studentId})")
    void studentCourseInsert(StudentCourseInsertDto studentCourseInsertDto);
    @Delete("delete from course_student where course_id=#{courseId} and student_id=#{studentId}")
    void courseDelete(StudentCourseDeleteDto studentCourseDeleteDto);
}
